In geometric analysis, an index theorem relates the difference of the numbers of solutions of two differential equations to the topological structure of the manifold or bundle concerned, sometimes using the heat kernels of two higher-order differential operators as an intermediary. In this paper, the case of quantum graphs is addressed. A quantum graph is a graph considered as a (singular) one-dimensional variety and equipped with a second-order differential Hamiltonian H (a "Laplacian") with suitable conditions at vertices. For the case of scale-invariant vertex conditions (i.e., conditions that do not mix the values of functions and of their derivatives), the constant term of the heat-kernel expansion is shown to be proportional to the trace of the internal scattering matrix of the graph. This observation is placed into the index-theory context by factoring the Laplacian into two first-order operators, H =A*A, and relating the constant term to the index of A. An independent consideration provides an index formula for any differential operator on a finite quantum graph in terms of the vertex conditions. It is found also that the algebraic multiplicity of 0 as a root of the secular determinant of H is the sum of the nullities of A and A*.